<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    /*获取项目的根路径*/
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://" + request.getServerName()+":"+request.getServerPort()+path+"/";
    /*basePath就是得到的跟路径类似于：http://localhost:8081/test/*/
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>shop</title>
    <script src="<%=basePath%>/js/jquery-3.7.1.min.js"></script>
    <!--网页图标-->
    <link rel="shortcut icon" href="<%=basePath%>/img/cat.png" type="image/x-icon">
    <link rel="stylesheet" href="<%=basePath%>/css/shop.css">
</head>
<body>
    <div class="main">
        <div class="content myFlex_y">
            <div class="title">
                <span style="margin-left: 10px">宠物店列表</span>
            </div>
            <div class="shopList">
                <c:forEach items="${requestScope.shopList}" var="shop">
                    <div class="shop">
                        <div class="information">
                            <span style="font-size: 17px">${shop.shopName}</span>
                            <span style="color: #999">地址：${shop.address}</span>
                            <span>
                                <c:forEach items="${shop.type.split(',')}" var="t">
                                    <span class="type">${t}</span>
                                </c:forEach>
                            </span>
                        </div>
                        <div class="ticket myFlex_x">
                            <div class="ticketInfo myFlex_y" style="width: 65%">
                                <span style="color: #999;margin-bottom: 5px;">
                                    ￥${requestScope.cat.getPriceByDiscount(shop.discount)}起
                                </span>
                                <span style="color: #999">
                                    ${shop.distance}
                                </span>
                            </div>
                            <!--隐藏域技术:保存品种猫和宠物店的id-->
                            <input date-catId="${requestScope.cat.id}" date-id="${shop.id}" class="buyTicket" type="button" value="团购套餐">
                        </div>
                    </div>
                </c:forEach>
            </div>
        </div>
    </div>
<script>
    $(".buyTicket").click(function (){
        // 点击按钮，跳转到团购套餐选择列表页
        // $(this):当前点击事件的标签对象，this是触发点击事件的input标签
        var catId=$(this).attr("date-catId");
        var shopId=$(this).attr("date-id");
        // 不打开新窗口，只在当前页面刷新
        window.location.href="<%=basePath%>/choice?method=getChoice&catId="+catId+"&shopId="+shopId;
    })
</script>
</body>
</html>